﻿using System;
using System.Collections.Generic;
using System.Text;

namespace FieldDevice.Devices
{
    class DeviceLD_B10:Device
    {
        public DeviceLD_B10(byte address, string name)
            : base(DeviceCategory.PowerMeter, address, name)
                {

                    Initialize();
                }
        public const ushort ADDR_Ta = 0x0000;
        public const ushort ADDR_Tb = 0x0001;
        public const ushort ADDR_Tc = 0x0002;
        public const ushort ADDR_Td = 0x0003;
        public const ushort ADDR_Alarm = 0x0000;

        public void  Initialize()
        {
            base.RequestRegister(ADDR_Ta, 4);
            base.RequestRegister(ADDR_Alarm, 1);
        }

        protected override float Translate(byte[] value, int begin, ushort registeraddress)
        {
            short tmpValue = value[begin];
            tmpValue <<= 8;
            tmpValue += value[begin + 1];
            switch (registeraddress)
            { 
                case ADDR_Ta:
                    if (tmpValue == 0x6000) 

                    RecordRead("Temper_A", tmpValue / 10.0f);
                    break;
                case ADDR_Tb:
                    RecordRead("Temper_B", tmpValue / 10.0f);
                    break;
                case ADDR_Tc:
                    RecordRead("Temper_C", tmpValue / 10.0f);
                    break;
                case ADDR_Td:
                    RecordRead("Temper_D",tmpValue/10.0f);
                    break;
                default:
                    break;
            
            }
            return 0.0f;
        }

    }
}
